{{#extends @html/widgets/node_widget.html}}
{{:widget_div_name}}communities{{/:widget_div_name}}

{{:widget_body}}
{{!connect "screen/widgets/wg-communities.css"}}
<div class="list-">
	{{!for widget.content.communities do=@:community_item}}{{:community_item}}
	<div class="item-">
		<h4><a href="{{/}}{{*community_url}}">{{*title}}</a></h4>
		<div class="desc-">{{*mod | safe}}</div>
	</div>
	{{/:community_item}}
</div>
{{/:widget_body}}

{{:widget_title}}<a href="{{/}}allcommunities">{{widget.title}}</a>{{/:widget_title}}

{{:community}}
<input type="checkbox" style="display:inline;width: 24px;" class="commcheck-" id="community{{*oid}}"{{?*checked}} checked="checked"{{/?}} name="community_list[]" value="{{*oid}}">
<label for="community{{*oid}}" style="display:inline; margin-left: 24px;">{{*title}}</label><br />
{{/:community}}

{{:settings}}
<div class="popup-widgets" id="settings_container">
	<form action="" id="settingsform">
	<input type="hidden" name="widget_id" value="{{settings.id}}" id="widget_id" />
	<h2 class="title-">Список сообществ</h2>
	<div class="content-" style="height: 400px; overflow: auto;">
		<fieldset class="fieldset- header- text-">
			<label>Заголовок</label>
			<input type="text" name="title" value="{{settings.title}}" />
			<div class="comment-">Не более 100 символов</div>
		</fieldset>
		<fieldset class="fieldset- header- text-">
			<label>Количество сообществ</label>
			<input type="text" name="communitiescount" value="{{settings.communitiescount}}" />
		</fieldset>
		<fieldset class="fieldset- header- text-">
			<label>Показывать сообщества:</label>
			<input type="radio" style="display:inline;width: 24px;" id="from_node" name="from" value="node"{{?'node'==settings.from || !settings.from}} checked="checked"{{/?}} />
			<label for="from_node" style="display:inline; margin-left: 24px;"> всего узла</label><br />
			<input type="radio" style="display:inline;width: 24px;" id="from_community" name="from" value="community"{{?'community'==settings.from}} checked="checked"{{/?}} />
			<label for="from_community" style="display:inline; margin-left: 24px;">обязательны к показу</label><br />
			{{!for settings.community do=@:community}}
		</fieldset>
	</div>
	{{@:settingsbutton}}
	</form>
	<script>
	jQuery("#from_node").bind("click", function(){
		setCheckBoxRights()
	});
	jQuery("#from_community").bind("click", function(){
		setCheckBoxRights()
	});
	jQuery().ready( function(){
		setCheckBoxRights();
	});

	function setCheckBoxRights() {
		var from_node = jQuery("#from_node").get(0).checked;
		jQuery("#settings_container").find("input.commcheck-").each(function(){
			if ( from_node ) {
				this.disabled = true;
				this.checked = false;
			} else {
				this.disabled = false;
			}
		});
	}
	</script>
</div>
{{/:settings}}
